package pattern5.ProducerConsumer.demo1.msgServer;


import com.alibaba.fastjson.JSON;
import utils.PrintUtil;

/**
 * @创建人 liweijia
 * @创建时间 2022/7/29
 * @描述 程序的主要用途
 */
public abstract class Producer {
    /**
     * 消息管理者
     */
    private final MsgManager msgManager;


    public Producer(MsgManager msgManager) {
        this.msgManager = msgManager;
    }

    public void send(Msg msg) {
        PrintUtil.print(String.format("\t发送消息[%s]", JSON.toJSONString(msg.getMsg())));
        msgManager.send(msg);
    }
}
